#include <iostream>
#include "SmartPtr.h"
using namespace std;
//void test1()
//{
//	//zyb::SmartPtr<int> sp1(new int(99));
//	//cout << sp1[0] << endl << endl;
//	//cout << *sp1 << endl;
//	//zyb::SmartPtr<int> sp2(sp1);
//	//std::cout << "hello shared_ptr" << std::endl;
//
//	zyb::SmartPtr<string> sps1(new string("zzzzzzzzzzzzzzz"));
//	zyb::SmartPtr<string> sps2(sps1);
//	sps1[0] += "uuuuuuuuuuuuuu";
//	zyb::SmartPtr<string> sps3(new string("sguigasuisaha"));
//	zyb::SmartPtr<string> sps4(new string("sguigasuisaha"));
//	sps3 = sps1;
//}
 
template<class T>
class listnode
{
public:
	listnode(const T val = 1)
		:_val(val)
		,_next(nullptr)
		,_prev(nullptr)
	{}
	~listnode()
	{
		cout << "~listnode()" << endl;
	}
public:
	T _val;
	zyb::weak_ptr<listnode<T>> _next;
	zyb::weak_ptr<listnode<T>> _prev;
};
int main()
{
	zyb::shared_ptr<listnode<int>> sp1(new listnode<int>);
	zyb::shared_ptr<listnode<int>> sp2(new listnode<int>);
	cout << sp1.use_count() << endl;
	cout << sp2.use_count() << endl;

	sp1->_next = sp2;
	sp2->_prev = sp1;
	cout << sp1.use_count() << endl;
	cout << sp2.use_count() << endl;
	return 0;
}
//void printodds(int* p1, int n)
//{
//	for (int i = 0; i < n; i++)
//	{
//		cout << *(p1 + i) << endl;
//	}
//}
//void printodds(int a[], int n)
//{
//	for (int i = 0; i < n; i++)
//	{
//		cout << a[i] << endl;
//	}
//}
//int main()
//{
//	int arr[10];
//	for (int i = 0; i < 10; i++) cin >> arr[i];
//	//cout << arr[10] << endl;
//	printodds(&arr[0], sizeof(arr) / sizeof(arr[0]));
//	return 0;
//}